import request from '@/router/axios';

export const getList = (current, size, params) => {
  return request({
    url: '/api/beetles-business/thirdpt-conf/page',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

export const getDetail = (id) => {
  return request({
    url: '/api/beetles-business/thirdpt-conf/detail',
    method: 'get',
    params: {
      id
    }
  })
}

export const remove = (ids) => {
  return request({
    url: '/api/beetles-business/thirdpt-conf/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const add = (row) => {
  return request({
    url: '/api/beetles-business/thirdpt-conf/submit',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: '/api/beetles-business/thirdpt-conf/submit',
    method: 'post',
    data: row
  })
}

/*验证保存飞书配置*/
export const fieShuConf = (data) =>{
  return request({
    url: '/api/beetles-business/feishu_conf/save_feishu',
    method: 'post',
    data: data
  })
}

/*保存企业微信群*/
export const informGroup = (name,address,groupType) =>{
  return request({
    url: '/api/beetles-business/inform_group/save_weixin_group',
    method: 'post',
    params: {
      name,
      address,
      groupType
    }

  })
}
/*获取并保存最新飞书群*/
export const saveFeiShuGroup = (feiShu) =>{
  return request({
    url: '/api/beetles-business/inform_group/save_feishu_group',
    method: 'post',
    data: feiShu
  })
}

/*选择通知方式*/
export const selectInformGroup = (way) =>{
  return request({
    url: '/api/beetles-business/template/select_inform_group',
    method: 'get',
    params: {
      way,
    }
  })
}

/*保存模板*/
export const saveTemplateConf = (data) =>{
  return request({
    url: '/api/beetles-business/template/save_new_template',
    method: 'post',
    data: data
  })
}

/*自定义分页*/
export const getPage = (current,size, params) =>{
  return request({
    url: '/api/beetles-business/template/page',
    method: 'get',
    params: {
      current,
      size,
      ...params
    }
  })
}

/*保存全局配置*/
export const globalConfAlter = (data) =>{
  return request({
    url: '/api/beetles-business/offer_notice_conf/global_conf',
    method: 'post',
    data: data
  })
}

/*获取飞书appId和app密匙*/
export const getFeiShuApp = () =>{
  return request({
    url: '/api/beetles-business/feishu_conf/get_feishu_app',
    method: 'get'
  })
}
/*通知配置查看*/
  export const deleteTemplate = (id) =>{
    return request({
      url: '/api/beetles-business/template/delete',
      method: 'get',
      params: {
        id
      }
    })
  }

  /*通知配置编辑*/
  export const getTemplate = (id) =>{
    return request({
      url: '/api/beetles-business/template/get',
      method: 'get',
      params: {
        id
      }
    })
  }

/**
 * 反显全局配置
 */
export const getGlobalConf = () =>{
  return request({
    url: '/api/beetles-business/offer_notice_conf/get_global_conf',
    method: 'get'
  })
}
/*反显微信群*/
export const getWeiXinGroup = () =>{
  return request({
    url: '/api/beetles-business/inform_group/get_weixin_group',
    method: 'get'
  })
}
/*删除微信群*/
export const dleWeiXinGroup = (id) =>{
  return request({
    url: '/api/beetles-business/inform_group/del_weixin_group',
    method: 'get',
    params: {
      id
    }
  })
}

/*订单管理 查看单个通知配置详情*/
export const getTemplateInfom = (id) =>{
  return request({
    url: '/api/beetles-business/template/get_template_infom',
    method: 'get',
    params: {
      id
    }
  })
}

/*检查是否存在通知模板*/
export const checkNoticeTemplate = () =>{
  return request({
    url: '/api/beetles-business/offer_notice_conf/check_notice_template',
    method: 'get'
  })
}

/*检测全局配置开关*/
export const getConfSwitch = () =>{
  return request({
    url: '/api/beetles-business/offer_notice_conf/get_conf_switch',
    method: 'get'
  })
}

/*检测订单是否配置了通知配置*/
export const checkOfferNotice = () =>{
  return request({
    url: '/api/beetles-business/offer_notice_conf/check_offer_notice',
    method: 'get',
  })
}

/* 将通知模板中的内容更新至订单的通知配置中*/
export const upOfferNoticeConf = (data) =>{
  return request({
    url: '/api/beetles-business/offer_notice_conf/update_offer_notice_conf',
    method: 'post',
    data:data,
  })
}

export const getUserList = () =>{
  return request({
    url: '/api/beetles-business/feishu_conf/get_user_list',
    method: 'get',
  })
}

export const getFeishuUserList = () =>{
  return request({
    url: '/api/beetles-business/feishu_conf/get_feishu_user_list',
    method: 'get',
  })
}

export const saveFeishuUserList = (data) => {
  return request({
    url: '/api/beetles-business/feishu_conf/save_user_list',
    method: 'post',
    data: data,
  })
}

